var threshold=0.5;
module.exports={
    get:get,
    read:read,
    query:query,
    getUrl:getUrl,
    getAndRead:getAndRead,
    sync:sync
}

function mock(mockError,title,cb){
    setTimeout(()=>{
        if(mockError){
            cb({msg:title+'错误'});
        }else{
            cb(null,title);
        }
    },Math.random()*1000|0);
}

function get(mockError,cb){
    mock(mockError,'网络请求',cb);
}

function check(mockError,cb){
    mock(mockError,'验证',cb);
}

function read(mockError,cb){
    mock(mockError,'读取文件',cb);
}

function query(mockError,cb){
    mock(mockError,'查询数据库',cb);
}

function sync(mockError,cb){
    if(mockError){
        cb({msg:'同步调用错误'});
    }else{
        cb(null,'同步调用成功');
    }
}

function getUrl(mockError,param,cb){
    setTimeout(()=>{
        if(mockError){
            cb({msg:'网络请求错误-'+param});
        }else{
            cb(null,'网络请求成功-'+param);

        }
    },Math.random()*1000|0);
}

function getAndRead(mockError,cb){
    setTimeout(()=>{
        if(mockError){
            cb({msg:'网络请求或读取文件错误'});
        }else{
            cb(null,'网络请求成功&','&读取文件成功');
        }
    },Math.random()*1000|0);
}